package com.education.api.controller.admin.system;


import com.education.business.service.system.SystemAdminService;
import com.education.common.base.BaseController;
import com.education.common.model.PageInfo;
import com.education.common.util.Result;
import com.education.model.dto.AdminRoleDto;
import com.education.model.entity.SystemAdmin;
import com.education.model.request.PageParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 余一
 * @since 2021-09-10
 */
@RestController
@RequestMapping("/system/admin")
public class SystemAdminController extends BaseController {
    @Autowired
    private SystemAdminService systemAdminService;

    @GetMapping
    public Result<PageInfo<SystemAdmin>> list(PageParam pageParam, SystemAdmin systemAdmin){
        return Result.success(systemAdminService.listPage(pageParam,systemAdmin));
    }

    @GetMapping("selectById")
    public Result selectById(Integer id){
        return Result.success(systemAdminService.selectById(id));
    }

    @PostMapping
    public Result saveOrUpdate(@RequestBody AdminRoleDto adminRoleDto){
        systemAdminService.saveOrUpdate(adminRoleDto);
        return Result.success();
    }

    @DeleteMapping("{id}")
    public Result deleteById(@PathVariable Integer id){
       return systemAdminService.deleteById(id);
    }
}
